import scrapy

class MySpider(scrapy.Spider):
    name = "500wan_lottery"
    allowed_domains = ["500.com"]
    start_urls = [
        "https://www.500.com/zqdc.php"  # 500wan网的竞猜页面
    ]

    def parse(self, response):
        # 提取竞猜数据
        for game in response.css('div.match_list li'):
            yield {
                'match_time': game.css('span.match_time::text').get(),
                'team_a': game.css('span.team_a::text').get(),
                'team_b': game.css('span.team_b::text').get(),
                'odds_a': game.css('span.odds_a::text').get(),
                'odds_draw': game.css('span.odds_draw::text').get(),
                'odds_b': game.css('span.odds_b::text').get(),
            }

        # 如果需要翻页，可以提取下一页的链接并递归调用 parse
        next_page = response.css('a.next_page::attr(href)').get()
        if next_page:
            yield response.follow(next_page, self.parse)